import time

import requests
import json
from ip import get_ip




def get_resid(webid,name,cridecode,ip=None,port=None):

    headers = {
    "accept": "application/json, text/plain, */*",
    "accept-language": "zh-CN,zh;q=0.9",
    "content-type": "application/json",
    "device": "0",
    "device-id": "BbWAUQDREaTLrCfS/tVO49ROQhcwywjBBpQce9kBPl8M2WIIZgBkIfhCHpJMQNJHZWRNOWcAmPyca6djAE+HbOQ==",
    "eagleeye-pappname": "fyw9n1jhpf@e3fdbf165821069",
    "eagleeye-sessionid": "ghmsd0446d3c1guwOshRjjL62agy",
    "eagleeye-traceid": "c2cc6ef01724396000841103621069",
    "h5version": "v1.0.0",
    "origin": "https://zhengce.qizhidao.com",
    "priority": "u=1, i",
    "referer": "https://zhengce.qizhidao.com/",
    "sec-ch-ua": "\"Chromium\";v=\"128\", \"Not;A=Brand\";v=\"24\", \"Google Chrome\";v=\"128\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-site",
    "signature": "55cf2c80809f29da8aef0b5f0e7d39b1.ikw48n",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
    "user-agent-web": "X/95abcb54432560b72a9f88fe3f8bbe83"
    }
    cookies = {
        # "wz_uuid": "X%2F437a7e241eca64bfd1ee2e06cd96fc9d",
        "sajssdk_2015_cross_new_user": "1",
        "sensorsdata2015jssdkcross": "%7B%22distinct_id%22%3A%221917d037db339a-0cb252742a6bbd-26001151-2073600-1917d037db4673%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E4%BC%81%E7%9F%A5%E9%81%93%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.baidu.com%2Fs%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTkxN2QwMzdkYjMzOWEtMGNiMjUyNzQyYTZiYmQtMjYwMDExNTEtMjA3MzYwMC0xOTE3ZDAzN2RiNDY3MyJ9%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%22%2C%22value%22%3A%22%22%7D%2C%22%24device_id%22%3A%221917d037db339a-0cb252742a6bbd-26001151-2073600-1917d037db4673%22%7D",
        "sensorsdata2015jssdkchannel": "%7B%22prop%22%3A%7B%22_sa_channel_landing_url%22%3A%22%22%7D%7D",
        "Hm_lvt_9ea3e7293b7c088e0d2c88874b63e7dd": "1724379267",
        "HMACCOUNT": "1AD8AE6F81C939B5",
        "s_webp": "s",
        "acw_tc": "2f6a1fa217243959827251593e20ff57a444671f47cb2147974541192bb54e",
        "x-web-ip": "121.199.42.214, 119.23.123.179, 120.78.44.142, 100.121.108.29",
        "Hm_lpvt_9ea3e7293b7c088e0d2c88874b63e7dd": "1724395986",
        "accessToken": "",
        "token": ""

    }
    url = "https://app.qizhidao.com/qzd-bff-marketing/qzd/v2/marketing/match"





    data = {
        "companyName": name,
        "creditCode": cridecode,
        "fak": "",
        "fal": "",
        "fb": "",
        "fx": "",
        "source": 1,
        "industryCode1": "",
        "industryCode2": "",
        "equipmentPurchaseMoney": "",
        "bankLoan": 0,
        "talentType": [],
        "positive": 1
    }
    data = json.dumps(data, separators=(',', ':'))
    # proxy_ip,proxy_port =get_ip()
    # print("ip::",proxy_ip,proxy_port)
    proxies ={
        'http': f'socks5://18551441704:18551441704@{ip}:{port}',
        'https': f'socks5://18551441704:18551441704@{ip}:{port}'
    }
    while True:
        if ip !=None:
            response = requests.post(url, headers=headers, cookies=cookies, data=data,proxies=proxies,timeout=5)
        else:
            response = requests.post(url, headers=headers, cookies=cookies, data=data,timeout=5)
        print("resid", response.json())
        if json.loads(response.text).get("success") == False:
           pass

        return response.json().get("data")

if __name__=='__main__':
    result=get_resid(webid=None,name='苏州新区高新技术产业股份有限公司',cridecode='9132000025161746XP')
    print(result)